import { ProductVendorIdEnum } from '@app/config/productEnum'

class VendorStore {
  /** 原始 vendor 对象 */
  vendor: IVendorObj
  /** 京喜店铺屏蔽商品标签 */
  isJXZY: boolean = false
  /** 店铺被选中 */
  isChecked: boolean = false
  /** 店铺是否可选 isNoCheck === 1 不可选 */
  checkDisabled: boolean = false

  constructor(vendor: IVendorObj) {
    this.vendor = vendor
    this.setIsJXZY()
    this.setIsChecked()
    this.setCheckDisabled()
  }

  private setIsJXZY() {
    const vendor = this.vendor
    this.isJXZY = (vendor && vendor.cannotJump && vendor.vendorId === ProductVendorIdEnum.VENDORID_JX_ZY) || false
  }

  private setIsChecked() {
    this.isChecked = this.vendor.checkType === 1
  }

  private setCheckDisabled() {
    this.checkDisabled = this.vendor.isNoCheck === 1
  }
}

export default VendorStore
